﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Soapi.Domain;

namespace Soapi.Notify2
{
    /// <summary>
    /// Interaction logic for QuestionsView.xaml
    /// </summary>
    public partial class QuestionsView  
    {
        public QuestionsView()
        {
            InitializeComponent();
        }

        private Question Question
        {
            get
            {
                return (Question)DataContext;
            }
        }
        private void TextBlock_MouseUp(object sender, MouseButtonEventArgs e)
        {
            // open question page
            var siteUrl = Question.Site.SiteUrl;
            var questionId = Question.QuestionId;
            Process.Start(string.Format("{0}/questions/{1}", siteUrl, questionId));

        }

        private void TextBlock_MouseUp_1(object sender, MouseButtonEventArgs e)
        {
            // open user profile page
            var siteUrl = Question.Site.SiteUrl;

            if (Question.OwnerId.HasValue)
            {
                Process.Start(string.Format("{0}/users/{1}", siteUrl, Question.OwnerId.Value));
            }

            
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            SiteListItem site = Program.Settings.Sites.Find(Question.Site.ApiEndpoint);
            SiteIcon.ToolTip = site.Name;
            SiteIcon.Source = site.SiteIcon.Source;
        }
    }
}
